﻿//*************************************************************************
//面向服务的协作式智能交通系统仿真软件SoC-ITSS v2.1 alpha
//发布单位：西北工业大学--巴黎高科MINES机器人与群智能系统联合实验室
//团队负责人：张凯龙 Zhang Kailong
//团队成员：张大方、杨安胜、王敏、谢策、王雨佳、谢尘玉等
//联系我们：kl.zhang@nwpu.edu.cn
//2012-2021
//*************************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CyberCarSimulation.Bean;
using CyberCarSimulation.RoadModel;
using CyberCarSimulation.Regulation;

//*******************************************************
//
//文件名(File Name):           Map.cs
//
//数据表(Tables):              nothing 
//
//作者(Author):                谢策
//
//          修改理由：         完善属性
//
//*******************************************************
namespace CyberCarSimulation.RoadModel
{
    class Map
    {
        private string ID;                            //地图ID
        private int Height;                           //地图长度
        private int Width;                            //地图宽度
        private int LengthIntNum;                     //地图长几个路口
        private int WidthIntNum;                      //地图宽几个路口
        private int IntNum;                           //附图上所以路口个数
        private string IP;                            //地图对应的IP
        private string MapImageURL;                   //地图图片的URL

        //private List<Way> WayList;                    //地图包含的道路集合

        private List<Intersection> IntersectionList;  //地图包含的路口集合

        private string[,] RelationShip;               //地图道路的关系矩阵
        private double[,] RelationWeight;              //地图的道路权值矩阵

        public List<Vehicle> GlobalVehicleList = new List<Vehicle>();     //全局的所有的车辆队列  

        public List<C2VMessage> C2VBuffer = new List<C2VMessage>();       //存储交通云给车辆的消息
        public List<V2CMessage> V2CBuffer = new List<V2CMessage>();       //存储车辆给交通云的消息
        
        //无参构造函数
        public Map()
        {
        }

        //有参构造函数
        public Map(string ID, int Height, int Width,
                   List<Intersection> IntersectionList, double[,] RelationWeight, 
                   string[,] RelationShip)
        {
            this.ID = ID;
            this.Height = Height;
            this.Width = Width;
            this.IntersectionList = IntersectionList;
            this.RelationWeight = RelationWeight;
            this.RelationShip = RelationShip;
        }

        //返回道路唯一标示ID
        public string GetID() 
        {
            return this.ID;
        }

        //设置道路唯一标示ID
        public void SetID(string ID)
        {
            this.ID = ID;
        }

        //返回地图高度
        public int GetHeight() 
        {
            return this.Height;
        }

        //设置地图的高度
        public void SetHeight(int Height)
        {
            this.Height = Height;
        }

        //返回地图的宽度
        public int GetWidth() 
        {
            return this.Width;
        }

        //设置地图的宽度
        public void SetWidth(int Width)
        {
            this.Width = Width;
        }

        //获取地图长几个路口
        public int GetLengthIntNum() 
        {
            return this.LengthIntNum;
        }

        //设置地图长几个路口
        public void SetLengthIntNum(int LengthIntNum) 
        {
            this.LengthIntNum = LengthIntNum;
        }

        //获取地图宽几个路口
        public int GetWidthIntNum() 
        {
            return this.WidthIntNum;
        }

        //设置地图宽几个路口
        public void SetWidthIntNum(int WidthIntNum) 
        {
            this.WidthIntNum = WidthIntNum;
        }

        //获取路口总数
        public int GetIntNum() 
        {
            return this.IntNum;
        }

        //设置路口总数
        public void SetIntNum(int IntNum)
        {
            this.IntNum = IntNum;
        }

        //返回IP
        public string GetIP() 
        {
            return this.IP;
        }

        //获取IP
        public void SetIP(string IP)
        {
            this.IP = IP;
        }

        //获取地图文件的URL
        public string GetMapImageURL() 
        {
            return this.MapImageURL;
        }

        //设置地图文件的URL
        public void SetMapImageURL(string MapImageURL)
        {
            this.MapImageURL = MapImageURL;
        }
              

        //返回路口集合
        public List<Intersection> GetIntersectionList()
        {
            return this.IntersectionList;
        }

        //设置路口集合
        public void SetIntersectionList(List<Intersection> IntersectionList)
        {
            this.IntersectionList = IntersectionList;
        }

        //返回道路权值矩阵
        public double[,] GetRelationWeight()
        {
            return this.RelationWeight;
        }

        //设置道路权值矩阵
        public void SetRelationWeight(double[,] RelationWeight)
        {
            this.RelationWeight = RelationWeight;
        }

        //返回道路的连接关系
        public string[,] GetRelationShip()
        {
            return this.RelationShip;
        }

        //设置道路的连接关系
        public void SetRelationShip(string[,] RelationShip)
        {
            this.RelationShip = RelationShip;
        }      
       
        ////根据ID搜索对应的道路
        //public Way FindWayById(string ID) 
        //{
        //    Way FindWay = new Way();
        //    foreach(Way Way in this.WayList){
        //        if(Way.GetID().Equals(ID))
        //        {
        //            FindWay = Way;
        //        }
        //    }
        //    return FindWay;
        //}

        //根据ID找到对应的路口
        public Intersection FindIntersectionByID(string ID) 
        {
            Intersection FindIntersection = new Intersection();
            foreach (Intersection Intersection in this.IntersectionList) 
            {
                if (Intersection.GetID().Equals(ID)) {
                    FindIntersection = Intersection;
                }
            }
            return FindIntersection;
        }
             
    }
}
